import { Component, OnInit } from '@angular/core';
import { NzFormatEmitEvent } from 'ng-zorro-antd/core';

import { ApiService } from '~/api/services';
import { maptreedata } from '~/utils/funcs';

@Component({
  selector: 'app-category',
  templateUrl: './category.component.html',
  styleUrls: ['./category.component.scss']
})
export class CategoryComponent implements OnInit {

  private api: ApiService;
  nodes = [];
  constructor(apiSvr: ApiService) {
    this.api = apiSvr;
  }

  ngOnInit(): void {
    this.api.getCategory().subscribe(data => {
      this.nodes = maptreedata(data);
    });
  }

  nzEvent(event: NzFormatEmitEvent): void {
    console.log(event);
  }
}
